/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package xpath.threads;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;

/**
 *
 * @author Rishav
 */
public class Worker implements Runnable{
private XPath xPath;
    private final Document xmlDocument;
    private final String exp;
    public Worker(Document xmlDocument, String exp) {
        this.xPath = XPathFactory.newInstance().newXPath();
        this.xmlDocument = xmlDocument;
        this.exp = exp;        
    }

    @Override
    public void run() {
    try {
        xPath.compile(exp).evaluate(xmlDocument);
    } catch (XPathExpressionException ex) {
        Logger.getLogger(Worker.class.getName()).log(Level.SEVERE, null, ex);
    }
    }
    
}
